package nsoft.timeline.object; 

import java.util.ArrayList;


@SuppressWarnings("serial")
public class MArrayList extends ArrayList<String> {
	
	public boolean updateContentById(String id, String content){
		int idx = -1;
		for (int i = 0; i < this.size(); i++){
			if (this.get(i).contains(id)){
				idx = i;
				break;
			}
		}
		if (idx >= 0){
			this.remove(idx);
			this.add(idx, content);
			return true;
		}
		return false;
	}
	
	public boolean removeById(String id){
		int idx = -1;
		for (int i = 0; i < this.size(); i++){
			if (this.get(i).contains(id)){
				idx = i;
				break;
			}
		}
		if (idx >= 0){
			this.remove(idx);
			return true;
		}
		return false;
	}
	
	public String getContentById(String id){
		for (int i = 0; i < this.size(); i++){
			if (this.get(i).contains(id))
				return this.get(i);
		}
		return null;
	}
}
